IMPREG page# 0001 next
2: COMMENT ⊗   VALID 00043 PAGES
3: C REC  PAGE   DESCRIPTION
4: C00001 00001
5: C00006 00002    SUBTTL IMP SERVICE - REGULAR MESSAGE HANDLING
6: C00007 00003     REGULAR MESSAGE ON NON-ZERO LINK. HERE WE HAVE FOUND THE LINK TABLE ENTRY.
7: C00010 00004     ALLOCATION UNDERFLOW ERROR
8: C00011 00005     CONTROL MESSAGE
9: C00014 00006     ERROR MESSAGES FOR LINK ZERO MESSAGES
10: C00016 00007     NCP SECOND LEVEL PROTOCALL OPCODE DISPATCH TABLE
11: C00017 00008     ALLOCATE. BUMP COUNTERS - RETURN, DECREMENT HIS COUNTERS
12: C00019 00009     NOP - NO OPERATION AND COMDDS ERROR RETURNS
13: C00020 00010     GVB COMMAND. THEY WANT US TO RETURN SOME STORAGE.
14: C00022 00011     GVB COMMAND. HERE WE FORMAT A RET BLOCK
15: C00023 00012     INTERRUPTS
16: C00024 00013     REQUEST FOR CONNECTION
17: C00026 00014     ROUTINE TO SET HOST NUMBER AND EITHER LINK OR BYTE SIZE
18: C00028 00015     RFC PENDING. CLOCK REQUEST COMES BACK HERE
19: C00030 00016     RFC CONTINUED. HERE THERE EXISTS A SOCKET.
20: C00033 00017     RFC CONTINUED. HERE WE ARE GOING TO ESTABLISH A CONNECTION AND RETURN THE RFC
21: C00035 00018     CLS COMMAND
22: C00038 00019     CLS CONTINUED. HERE WE GOT A RECEIVE-SIDE CLS AND THERE IS A LINK TABLE ENTRY.
23: C00040 00020     ECHO COMMAND
24: C00041 00021     ERROR - INCOMMING!
25: C00042 00022     RESET REPLY
26: C00043 00023     RESET - PURGE OUR TABLES
27: C00046 00024     RESET - SCAN DOWN THE QUEUED RFC LIST FOR ENTRIES BY THIS GUY
28: C00048 00025     ERROR RECOVERY SYSTEM. POOT OUT MESSAGES TO EVERYONE WHO THINKS
29: C00050 00026     ERROR RECOVERY FOR LINK ZERO
30: C00052 00027     UTILITY ROUTINES FOR THE PRECEEDING ROUTINES - ERROR ROUTINE
31: C00054 00028     ROUTINE TO DELETE A LINK IN THE LINK TABLE.
32: C00056 00029     ROUTINE TO POLL ALL THE OTHER SITES FOR SIGNS OF LIFE
33: C00058 00030     ROUTINE TO PERIODICALLY CHECK AND MAKE SURE ALL IS OK
34: C00060 00031     ROUTINE TO SEND THE IMP SOME NOPS
35: C00062 00032
36: C00064 00033     ROUTINE TO DUMP AN INCOMMING COMMAND INTO THE DATA PORTION OF AN ERROR MESSAGE
37: C00065 00034     ROUTINE TO WAIT AT CLOCK LEVEL FOR A STANDARD FREE STORAGE BLOCK
38: C00066 00035     ROUTINE TO RELEASE THE STORAGE IN A LIST
39: C00067 00036     ROUTINE TO PLANT AN INTERRUPT REQUEST
40: C00068 00037     ROUTINE TO UNLINK THE TOP MESSAGE ON THE INPUT LIST
41: C00070 00038     ROUTINE TO SEND OUT A MESSAGE FROM CLOCK LEVEL ON LINK 0.
42: C00072 00039     ROUTINE TO FIND A DDB FROM LINK NUMBER IN A SECOND LEVEL
43: C00074 00040     ROUTINES TO PICK UP SOCKET NUMBERS AND STORE THEM FOR CLS, RTS, AND STR
44: C00075 00041     ROUTINE TO RETURN A CLS TO THE HOST WHOSE MESSAGE IS IN AC1
45: C00076 00042     ROUTINE TO MAKE UP A CLS BLOCK WITH EMPTY SOCKETS
46: C00077 00043     SEND CLOSE TO FOREIGN HOST
47: C00078 ENDMK
48: C⊗;
    IMPREG page# 0002 next  prev
50: SUBTTL IMP SERVICE - REGULAR MESSAGE HANDLING
51: ; REGULAR MESSAGE
52: 
53: REGULAR:
54:         LDB AC2,ELINKP          ; PICK UP HOST-LINK NUMBER
55:         TRNN AC2,377            ; CONTROL MESSAGE?
56:         JRST L0REG              ; YES, GO PICK UP NCP PROTOCAL OP-CODE
57:         SKIPN AC3,FFLNK
58:         JRST RMUNL
59:         SETZ DAT,
60: REGFRL: CAMN AC2,LNKTAB-1(AC3)
61:         JRST REGCRS             ; LINK NUMBER MATCHES, CHECK FOR RECEIVE-SIDE
62: REGINC: SOJG AC3,REGFRL
63:         JUMPE DAT,UNL
64: RMUNL:  TELCTR(RWNOSS,<INPUT WITH NO RECEIVE SIDE>)
65:         JRST PSCAN
66: 
67: IWCNO:  TELCTR(NIWCNO,<INPUT WITH CONNECTION NOT ENTIRELY OPEN>)
68:         JRST PSCAN
    IMPREG page# 0003 next  prev
70: ; REGULAR MESSAGE ON NON-ZERO LINK. HERE WE HAVE FOUND THE LINK TABLE ENTRY.
71: 
72: REGCRS: MOVE TEM,IMPLS-1(AC3)
73:         MOVEI DAT,(AC3)         ; NOTE THAT WE FOUND A SOCKET OF SOME KIND
74:         TRNE TEM,1
75:         JRST REGINC             ; SEND SIDE, SKIP THIS ONE.
76:         MOVE AC2,IMPSTB-1(AC3)  ; PICK UP STATUS BITS
77:         TLC AC2,RFCR!RFCS
78:         TLNE AC2,RFCR!RFCS      ; IS THE SOCKET ALL THE WAY OPEN?
79:         JRST IWCNO              ; NO, MUST BE COMPLETELY OPEN TO RECEIVE MESSAGES
80:         SKIPN DDB,IMPDDB-1(AC3) ; PICK UP DDB ADDRESS IF ANY
81:         JRST NODDB
82:         MOVE IOS,DEVIOS(DDB)    ; PICK UP IO STATUS WORD
83:         TLZE IOS,INPW           ; IS HE WAITING FOR INPUT?
84:         PUSHJ P,QRUN            ; YES, WAKE HIM UP
85:         MOVEM IOS,DEVIOS(DDB)
86:    MOVSI AC2,INTINP        ; GIVE HIM AN INPUT INTERRUPT
87:         PUSHJ P,INTCOM
88:         LDB AC2,SIZEP           ; PICK UP BYTE SIZE OF TRANSFER
89:         LDB AC3,COUNTP          ; AND LENGTH OF TRANSFER
90:         IMULI AC2,(AC3)         ; GET TOTAL NUMBER OF BITS IN TRANSFER
91:         ADDM AC2,BIIL(DDB)      ; NOTE THIS MANY MORE BITS IN THE INPUT LIST
92:         MOVNS AC2
93:         ADDM AC2,HBA(DDB)       ; DECREMENT BIT ALLOCATION
94:         AOS MIIL(DDB)           ; AND THIS MANY MORE MESSAGES IN THE INPUT LIST
95:         SOSL HMA(DDB)           ; DECREMENT MESSAGE ALLOCATION
96:         SKIPGE HBA(DDB)         ; DID BIT ALLOCATION UNDERFLOW?
97:         JRST CTROVF             ; YES, ERROR
98:         PUSHJ P,UNLNS           ; POP MESSAGE OFF INPUT LIST
99:         SKIPN AC2,INL(DDB)      ; DOES HE HAVE AN INPUT LIST?
100:       JRST REG1               ; NO, START ONE
101:         MOVSS AC2               ; GET POINTER TO LAST BLOCK IN RH
102:         HRLM AC1,TLINK(AC2)     ; LINK US ONTO HIS TAIL
103: REG2:   HRLM AC1,INL(DDB)       ; PUT US IN AS NEW LAST ELEMENT
104:         HRRZS TLINK(AC1)        ; NOTE THAT NOONE FOLLOWS US
105:         JRST IMPCLK
106: 
107: REG1:   HRRM AC1,INL(DDB)       ; PUT US IN AS FIRST ELEMENT
108:         JRST REG2
    IMPREG page# 0004 next  prev
110: ; ALLOCATION UNDERFLOW ERROR
111: 
112: CTROVF: ORI IOS,CTROV!IODERR
113:         MOVEM IOS,DEVIOS(DDB)
114:         PUSH P,AC1              ; SEND ERROR MESSAGE TO HOST
115:         PUSHJ P,MAKERB          ; MAKE UP AN ERROR BLOCK
116:         PUSHJ P,CLKWAIT
117:         PUSHJ P,OFILL           ; TAG ON HIS MESSAGE
118:         MOVEI AC3,CTO
119:         DPB AC3,BYTE3P
120:         PUSHJ P,CLKOUT          ; SEND IT OUT
121:         POP P,AC1
122:         JRST PSCAN
123: 
124: ; UNKNOWN LINK ERROR
125: 
126: SLUNL:  TELCTR(SLUNLK,<UNKNOWN LINK IN REGULAR MESSAGE>)
127:         PUSHJ P,UNLMER
128:         JRST L0XIT
    IMPREG page# 0005 next  prev
130: ; CONTROL MESSAGE
131: 
132: L0REG:  LDB AC3,SIZEP           ; YES, CHECK BYTE SIZE
133:         CAIE AC3,10             ; BETTER BE 8
134:         JRST ILLBS              ; ILLEGAL, GIVE ERROR
135:         MOVEI AC3,(AC1)         ; SEPARATE OUT INPUT BLOCK ADDRESS
136:         HRLI AC3,441000         ; MAKE UP AN 8-BIT BYTE POINTER FOR IT
137:         ADDI AC3,TDATA+2        ; MAKE IT POINT AT THE FIRST OPCODE
138:         MOVEM AC3,TBP(AC1)      ; SAVE IT IN INPUT BLOCK
139: L0MORE: ILDB DSER,TBP(AC1)      ; PICK UP OPCODE
140:         CAIL DSER,OPMAX         ; IS IT A LEGAL OPCODE?
141:         JRST RILLO              ; NO, GIVE ERROR
142:         LDB AC3,COUNTP          ; PICK UP LENGTH OF MESSAGE
143:         LDB TAC,[POINT 9,OPTAB(DSER),8]
144:         CAIL AC3,(TAC)          ; IS COMMAND AS LONG AS IT SHOULD BE?
145:         JRST L0CDSP             ; YES, DISPATCH
146:         TELCTR(BCMM,<SHORT CONTROL COMMAND>)
147:         PUSH P,AC1              ; SAVE INPUT MESSAGE
148:         PUSHJ P,MAKERB          ; MAKE UP AN ERROR BLOCK
149:         PUSHJ P,CLKWAIT
150:         PUSHJ P,EFILL           ; TAG ON HIS LEADER
151:         MOVEI AC3,SPS           ; GIVE HIM SHORT PARAMETER ERROR
152: RERR1:  DPB AC3,BYTE2P
153: RERR2:  PUSHJ P,CLKOUT
154:         POP P,AC1
155:         JRST PSCAN
156: 
157: L0CDSP: SUBI AC3,(TAC)          ; SHORTEN TOTAL MESSAGE BY THIS MUCH
158:         DPB AC3,COUNTP          ; AND THIS IS THE NEW MESSAGE LENGTH
159:         JRST @OPTAB(DSER)
160: 
161: L0XIT:  HRRZ AC1,ILIST          ; PICK UP POINTER TO MESSAGE
162:         LDB AC2,COUNTP          ; SEE IF THERE IS ANYTHING LEFT IN THIS MESSAGE
163:         JUMPE AC2,PSCAN
164:         JRST L0MORE
    IMPREG page# 0006 next  prev
166: ; ERROR MESSAGES FOR LINK ZERO MESSAGES
167: 
168: RILLO:  SKIPE RECOVER
169:         JRST PSCAN              ; IF ERROR RECOVERY IN PROGRESS, TOLERATE A BIT OF FOOLISHNESS
170:         SETOM RECOVER           ; OTHERWISE INITIATE RECOVERY SEQUENCE
171:         TELCTR(NILLOP,<ILLEGAL OPCODE>)
172:         PUSH P,AC1
173:         PUSHJ P,MAKERB
174:         PUSHJ P,CLKWAIT
175:         PUSHJ P,EFILL
176:         MOVEI AC3,ILO
177:         JRST RERR1
178: 
179: ILLBS:  SKIPE RECOVER
180:         JRST PSCAN              ; IF ERROR RECOVERY IN PROGRESS, TOLERATE A BIT OF FOOLISHNESS
181:         SETOM RECOVER           ; OTHERWISE INITIATE RECOVERY SEQUENCE
182:         TELCTR(BSILL,<ILLEGAL BYTE SIZE ON CONTROL COMMAND>)
183:         PUSH P,AC1
184:         PUSHJ P,MAKERB
185:         PUSHJ P,CLKWAIT
186:         PUSHJ P,OFILL
187:         MOVEI AC3,ILB
188:         DPB AC3,BYTE3P
189:         JRST RERR2
    IMPREG page# 0007 next  prev
191: ; NCP SECOND LEVEL PROTOCALL OPCODE DISPATCH TABLE
192: 
193: DEFINE Z (LENGTH,DSP) <XWD LENGTH*1000,DSP>
194: 
195: OPTAB:  Z(1,SNOPCN)     ; NO OPERATION
196:         Z(12,IRTS)      ; REQUEST FOR CONNECTION, RECEIVER TO SENDER
197:         Z(12,ISTR)      ; REQUEST FOR CONNECTION, SENDER TO RECEIVER
198:         Z(11,ICLS)      ; CLOSE
199:         Z(10,IALL)      ; ALLOCATE
200:         Z(4,IGVB)       ; GIVE BACK STORAGE
201:         Z(10,IRET)      ; STORAGE RETURNED
202:         Z(2,IINR)       ; INTERRUPT BY RECEIVER
203:         Z(2,IINS)       ; INTERRUPT BY SENDER
204:         Z(2,IECO)       ; ECHO REQUEST
205:         Z(2,IERP)       ; ECHO REPLY
206:         Z(14,IERR)      ; ERROR
207:         Z(1,IRST)       ; RESET
208:         Z(1,IRRP)       ; RESET REPLY
209: 
210: OPMAX←←.-OPTAB
    IMPREG page# 0008 next  prev
212: ; ALLOCATE. BUMP COUNTERS - RETURN, DECREMENT HIS COUNTERS
213: 
214: IALL:   PUSHJ P,COMDDS          ; PICK UP DDB OF CONNECTION
215:         JRST SLUNL              ; NON-EX CONNECTION
216:         JRST RD6NSE             ; NO SEND SOCKET
217:         JRST RD6CC              ; CONNECTION CLOSED OR NO DDB
218:         PUSHJ P,RD2B            ; GET 16 CONSECUTIVE BITS INTO AC2
219:         ADDM AC2,MAL(DDB)       ; BUMP HIS MESSAGE ALLOCATION
220:         PUSHJ P,RD4B            ; GET 32 BIT DATUM
221:         ADDM AC2,BAL(DDB)       ; BUMP BIT COUNTER
222:         MOVE IOS,DEVIOS(DDB)
223:         TLZE IOS,ALLW           ; WAITING FOR ALLOCATION
224:         PUSHJ P,QRUN            ; YES, WAKE HIM UP
225:         MOVEM IOS,DEVIOS(DDB)
226:         JRST L0XIT
227: 
228: ; RTN COMMAND.
229: 
230: IRET:   PUSHJ P,COMDDR          ; PICK UP DDB OF A RECEIVE-SIDE CONNECTION
231:         JRST SLUNL              ; NON-EX CONNECTION
232:         JRST RD6NSE             ; NO RECEIVE SIDE CONNECTION
233:         JRST RD6CC              ; CONNECTION CLOSED
234:         PUSHJ P,RD2B            ; PICK UP MESSAGE ALLOCATION
235:         MOVNS AC2
236:         ADDM AC2,HMA(DDB)       ; HE NOW HAS THAT MUCH LESS ALLOCATION
237:         PUSHJ P,RD4B            ; GET BIT ALLOCATION
238:         MOVNS AC2
239:         ADDM AC2,HBA(DDB)
240:         JRST L0XIT              ; END OF OPERATION
    IMPREG page# 0009 next  prev
242: ; NOP - NO OPERATION AND COMDDS ERROR RETURNS
243: 
244: SNOPCN: AOS SLNOPS              ; BUMP COUNT OF SECOND LEVEL NO-OPERATIONS
245:         JRST L0XIT
246: 
247: ; ERROR RETURNS FOR COMDDS CALLERS
248: 
249: RD6NSE: PUSHJ P,RD4B            ; PUSH BYTE POINTER ALONG
250: RD2NSE: PUSHJ P,RD2B
251: RCCANS: TELCTR(NSSC,<NO SEND-SIDE CONNECTION>)
252:         JRST L0XIT
253: 
254: RD6CC:  PUSHJ P,RD4B
255: RD2CC:  PUSHJ P,RD2B
256:         AOS NALWNC
257:         JRST L0XIT
    IMPREG page# 0010 next  prev
259: ; GVB COMMAND. THEY WANT US TO RETURN SOME STORAGE.
260: 
261: IGVB:   PUSHJ P,COMDDS
262:         JRST RD2NSE
263:         JRST RD2CC
264:         JRST SLUNL
265:         ILDB AC2,TBP(AC1)       ; PICK UP FIRST FRACTION BYTE
266:         CAILE AC2,200           ; FRACTION GREATER THAN ONE?
267:         MOVEI AC2,200           ; YES, GIVE IT ALL BACK
268:         IMUL AC2,MAL(DDB)       ; SEE HOW MUCH HE WANTS
269:         TRNE AC2,177            ; ROUND UP ALWAYS
270:         ADDI AC2,200
271:         LSH AC2,-7              ; AND THIS IS NUMBER OF BITS HE WANTS
272:         PUSH P,AC2
273:         MOVNS AC2
274:         ADDM AC2,MAL(DDB)
275: 
276:         ILDB AC2,TBP(AC1)       ; GET NEXT BYTE
277:         CAILE AC2,200           ; FRACTION GREATER THAN ONE?
278:         MOVEI AC2,200           ; YES, GIVE IT ALL BACK
279:         IMUL AC2,BAL(DDB)       ; SEE HOW MUCH HE WANTS
280:         TRNE AC2,177            ; ROUND UP ALWAYS
281:         ADDI AC2,200
282:         LSH AC2,-7              ; AND THIS IS NUMBER OF BITS HE WANTS
283:         PUSH P,AC2
284:         MOVNS AC2
285:         ADDM AC2,BAL(DDB)
    IMPREG page# 0011 next  prev
287: ; GVB COMMAND. HERE WE FORMAT A RET BLOCK
288: 
289:         PUSH P,AC1
290:         PUSHJ P,IMPGET          ; GET SOME STORAGE FOR A RET COMMAND
291:         PUSHJ P,CLKWAIT
292:         POP P,AC2
293:         MOVE AC2,TDATA(AC2)
294:         MOVEM AC2,TDATA(AC1)
295:         SETZM TDATA+1(AC1)
296:         SETZM TDATA+2(AC1)
297:         MOVEI AC3,10
298:         DPB AC3,SIZEP           ; BOTH SIZE AND COUNT ARE 8 BYTES
299:         DPB AC3,COUNTP
300:         MOVEI AC3,RET
301:         DPB AC3,OPCDP
302:         LDB AC3,[POINT 8,TDATA+2(AC2),15]
303:         DPB AC3,OLINKP          ; PUT IN LINK
304:         POP P,AC3
305:         LSH AC3,4
306:         MOVEM AC3,TDATA+3(AC1)
307:         POP P,AC3               ; PUT ALLOCATIONS BEING RETURNED IN FIRST 32 BITS
308:         DPB AC3,[POINT 16,TDATA+2(AC2),31]
309:         MOVEI AC3,4
310:         MOVEM AC3,TWC(AC1)
311:         PUSHJ P,CLKOUT
312:         JRST L0XIT
    IMPREG page# 0012 next  prev
314: ; INTERRUPTS
315: 
316: IINR:   PUSHJ P,COMDDS
317:         JRST SLUNL
318:         JRST RCCANS
319:         JRST L0XIT
320:         MOVSI AC2,INTINR        ; INTERRUPT BY RECEIVER
321:         ORM AC2,IMPSTB-1(AC3)   ; PUT IN STATUS BITS TOO
322:         PUSHJ P,INTCOM
323:         JRST L0XIT
324: 
325: IINS:   PUSHJ P,COMDDR
326:         JRST SLUNL
327:         JRST RCCANS
328:         JRST L0XIT
329: ;       JRST SLUNL              ; ?? comddr only has 4 returns, not 5
330:         MOVSI AC2,INTINS        ; INTERRUPT BY SENDER
331:         ORM AC2,IMPSTB-1(AC3)
332:         PUSHJ P,INTCOM
333:         JRST L0XIT
    IMPREG page# 0013 next  prev
335: ; REQUEST FOR CONNECTION
336: 
337: XTTIME←←TDATA
338: SOCK1←←TDATA+1          ; BLOCK LOCATIONS FOR PENDING MESSAGES
339: SOCK2←←TDATA+2
340: 
341: IRTS:
342: ISTR:   PUSHJ P,RD4B            ; GET FIRST SOCKET NUMBER (FOREIGN SOCKET)
343:         MOVE UUO,AC2            ; SAVE FOREIGN SOCKET IN UUO
344:         PUSHJ P,RD4B
345:         MOVE JDAT,AC2           ; SAVE LOCAL SOCKET NUMBER IN JDAT
346:         SKIPN AC3,FFLNK         ; SCAN LINK TABLE FOR IT
347:         JRST MAKPND
348: ISTRL:  CAMN AC2,IMPLS-1(AC3)
349:         JRST ISTRFS
350:         SOJG AC3,ISTRL
351: MAKPND: AOS AC3,FFLNK           ; MAKE UP NEW INDEX NUMBER
352:         CAILE AC3,MAXNLK        ; OVERFLOWED TABLES?
353:         JRST NOLNK              ; YES, CANNOT ACCEPT RFC
354:         SETZM IMPDDB-1(AC3)
355:         MOVEM AC2,IMPLS-1(AC3)
356:         MOVEM UUO,IMPFS-1(AC3)
357:       SETZM IMPRFQ-1(AC3)     ; CLEAR OUT OLD GARBAGE
358:         PUSHJ P,SETHLB          ; SET HOST NUMBER AND EITHER BYTE SIZE OR LINK NUMBER
359: MAKPN:  PUSHJ P,IMPGET          ; GET A BLOCK FOR PENDING MESSAGE
360:         PUSHJ P,CLKWAIT
361:         MOVEM JDAT,SOCK2(AC1)   ; SAVE SOCKET NUMBER
362:         MOVEM UUO,SOCK1(AC1)
363:         HRLI AC1,PNDG           ; MAKE IT PEND IN A CLOCK QUEUE REQUEST
364:         CONO PI,PIOFF
365:         IDPB AC1,CLKQ
366:         CONO PI,PION
367:         MOVEI AC2,4*=60*JIFSEC
368:         MOVEM AC2,XTTIME(AC1)   ; WE WILL PEND FOR 4 MINUTES
369:         MOVSI AC2,RFCR!ANYC
370:         MOVEM AC2,IMPSTB-1(AC3) ; NOTE THAT A STR HAS BEEN RECEIVED
371:         JRST L0XIT
    IMPREG page# 0014 next  prev
373: ; ROUTINE TO SET HOST NUMBER AND EITHER LINK OR BYTE SIZE
374: 
375: SETHLB: LDB AC2,SRCP            ; SET HOST NUMBER IF NOT ALREADY SET
376:         DPB AC2,[POINT 8,LNKTAB-1(AC3),27]
377:         ILDB AC2,TBP(AC1)       ; PICK UP SIZE FIELD
378: SETHB:  CAIN DSER,STR           ; IF SENDER TO RECEIVER,
379:         MOVEM AC2,IMPBS-1(AC3)  ; THEN LET HIM SET THE BYTE SIZE
380:         CAIN DSER,RTS           ; OTHERWISE, LET HIM SET LINK NUMBER
381:         DPB AC2,[POINT 8,LNKTAB-1(AC3),35]
382:         POPJ P,
383: 
384: ; GET HERE IF THERE IS NO MORE ROOM IN THE LINK TABLE
385: 
386: NOLNK:  IBP TBP(AC1)            ; SKIP OVER SIZE-LINK FIELD
387:         PUSHJ P,RTNCLS          ; SEND HIM BACK A CLOSE
388:         SOS FFLNK               ; UNDO THE DAMAGE
389:         TELCTR(NNOLNK,<RFC RECEIVED BUT NOT LINK AVAILABLE>)
390:         JRST L0XIT              ; INCOMMING MESSAGE HAS BEEN USED FOR THE CLOSE
    IMPREG page# 0015 next  prev
392: ; RFC PENDING. CLOCK REQUEST COMES BACK HERE
393: 
394: PNDG:   MOVEI AC1,(DAT)
395:         SKIPN AC3,FFLNK         ; FIND INDEX OF PARTIAL CONNECTION
396:         JRST RELLST             ; IF NONE, FORGET IT
397:         MOVE AC2,SOCK2(AC1)     ; PICK UP LOCAL SOCKET NUMBER
398:         MOVE UUO,SOCK1(AC1)
399: PNDGL:  CAMN AC2,IMPLS-1(AC3)
400:         CAME UUO,IMPFS-1(AC3)
401:         JRST PNDGI
402:         MOVE TEM,IMPSTB-1(AC3)  ; PICK UP STATUS BITS
403:         TLNE TEM,RFCS!CLSR!CLSS
404:         JRST RELLST             ; IF ANYTHING HAS HAPPENED ON THE LINE, LEAVE
405: PNDGN:  SOSLE XTTIME(AC1)       ; OTHERWISE, COUNT DOWN
406:         JRST DPYTIM
407:         PUSH P,AC1
408:         PUSHJ P,IMPGET          ; SEND HIM A CLS
409:         JRST [  POP P,AC1
410:                 JRST DPYTIM]
411:         PUSHJ P,SNCLS           ; SEND A CLOSE
412:         POP P,AC1
413:         JRST RELLST
414: 
415: PNDGI:  SOJG AC3,PNDGL
416:         JRST RELLST
    IMPREG page# 0016 next  prev
418: ; RFC CONTINUED. HERE THERE EXISTS A SOCKET.
419: 
420: ISTRFS: MOVE DAT,IMPSTB-1(AC3)  ; PICK UP STATUS BITS
421:         TLNE DAT,RFCS           ; HAS AN RFC BEEN SENT TO IT?
422:         JRST CLRFCW             ; YES, CONNECTION HAS BEEN MADE
423:         SKIPN LNKTAB-1(AC3)     ; IS HOST NUMBER INITIALIZED?
424:         JRST CHKFSK             ; NO, OURS WILL WORK THEN
425:         LDB DAT,ELINKP          ; PICK UP HOST NUMBER
426:         XOR DAT,LNKTAB-1(AC3)
427:         TRNN DAT,177400         ; TWO RFC'S?
428:         JRST ISTRMP             ; YES, CHECK FOR UNOPENED SIDE OF CONNECTION
429: ISTRF3: MOVEI TEM,(AC1)
430:         PUSHJ P,IMPGET
431:         PUSHJ P,CLKWAIT
432:         DPB DSER,OPCDP          ; MAKE UP NEW INPUT MESSAGE BLOCK
433:         MOVE AC2,UUO            ; WITH JUST THIS RFC IN IT
434:         PUSHJ P,PSOCK1
435:         MOVE AC2,JDAT
436:   PUSHJ P,PSOCK2
437:         ILDB AC2,TBP(TEM)       ; PICK UP SIZE-LINK FIELD
438:         DPB AC2,SZLKP
439:         MOVE AC2,TDATA(TEM)     ; GET LEADER
440:         MOVEM AC2,TDATA(AC1)
441:         SETZM TDATA+1(AC1)
442:         MOVEI AC2,10
443:         DPB AC2,SIZEP
444:         MOVEI AC2,12
445:         DPB AC2,COUNTP
446:         SKIPN AC2,IMPRFQ-1(AC3) ; SEE IF THERE IS A WAITING RFC LIST
447:         JRST ISTRF2             ; NO, WE ARE ONLY ELEMENT
448:         MOVSS AC2               ; POINT US TO TAIL OF LIST
449:         HRLM AC1,TLINK(AC2)
450: ISTRF1: HRLM AC1,IMPRFQ-1(AC3)
451:         HRRZS TLINK(AC1)
452:         JRST L0XIT
453: 
454: ISTRF2: HRRM AC1,IMPRFQ-1(AC3)
455:         JRST ISTRF1
456: 
457: CLRFCW: LDB AC2,ELINKP          ; PICK UP HOST #
458:         XOR AC2,LNKTAB-1(AC3)
459:         TRNE AC2,177400         ; SAME HOST NUMBER?
460:         JRST ISTRF3             ; NO, QUEUE RFC
461: ISTRMP:      TLNN DAT,RFCR           ; HAS THIS SIDE OF THE CONNECTION BEEN ESTABLISHED?
462:         JRST CHKFSK             ; NO, PUT US IN THERE
463:         CAME UUO,IMPFS-1(AC3)   ; DOES THE FOREIGN SOCKET MATCH?
464:         JRST ISTRF3             ; NO, QUEUE US UP
465: TWORFC: AOS N2RFCS
466:         IBP TBP(AC1)
467:         JRST L0XIT
    IMPREG page# 0017 next  prev
469: ; RFC CONTINUED. HERE WE ARE GOING TO ESTABLISH A CONNECTION AND RETURN THE RFC
470: 
471: CHKFSK: SKIPL IMPFS-1(AC3)      ; HAS SOCKET BEEN INITIALIZED
472:         CAMN UUO,IMPFS-1(AC3)   ; YES, DOES IT MATCH
473:         JRST CLRFC1             ; YES, COMPLETE CONNECTION
474:         JRST ISTRF3             ; NO, QUEUE US UP
475: 
476: CLRFC1: MOVEM UUO,IMPFS-1(AC3)
477:         PUSHJ P,SETHLB          ; SET HOST NUMBER AND LINK (OR BYTE SIZE)
478:         MOVSI AC2,RFCR
479:         PUSHJ P,CSTAT           ; CHANGE STATUS BITS
480:         SKIPN DDB,IMPDDB-1(AC3)
481:         JRST MAKPN
482:         MOVSI AC2,RFCS
483:         TDNE AC2,IMPSTB-1(AC3)  ; HAVE WE ALREADY SENT HIM AN RFC?
484:         JRST CLRFC2             ; YES, SKIP OVER THIS PART
485:         PUSHJ P,IMPGET          ; GET US SOME F.S.
486:         PUSHJ P,CLKWAIT         ; WAIT FOR IT IF NECESSARY
487:         PUSHJ P,CLRBLK
488:         CAIN DSER,RTS           ; SEND HIM THE OPPOSITE FLAVOR RFC
489:         MOVEI TEM,STR
490:         CAIN DSER,STR
491:         MOVEI TEM,RTS
492:         DPB TEM,OPCDP
493:         PUSHJ P,MAKRF           ; SET THE REST OF THE MESSAGE, SOCKETS, BYTE SIZE OR LINK, ETC.
494:         PUSHJ P,CLKOUT
495: CLRFC2: MOVE IOS,DEVIOS(DDB)
496:         TLZE IOS,RFCW
497:         PUSHJ P,QRUN
498:         MOVEM IOS,DEVIOS(DDB)
499:         JRST L0XIT
    IMPREG page# 0018 next  prev
501: ; CLS COMMAND
502: 
503: ICLS:   PUSHJ P,RD4B            ; PICK UP FOREIGN SOCKET
504:         MOVE UUO,AC2
505:         PUSHJ P,RD4B
506:         MOVE JDAT,AC2
507:         SKIPN AC3,FFLNK
508:         JRST RTCL               ; NOBODY HOME.
509: ICLSL:  CAMN JDAT,IMPLS-1(AC3)
510:         JRST RCLSRC             ; RECEIVE SIDE SOCKET FOUND
511:         SOJG AC3,ICLSL
512: RTCL:   AOS NSCLSS              ; BUMP NUMBER OF STRANGE CLSS
513:         JRST L0XIT
514: 
515: RCLSRC: LDB AC2,ELINKP          ; PICK UP HOST-LINK NUMBER
516:         XOR AC2,LNKTAB-1(AC3)
517:         CAMN UUO,IMPFS-1(AC3)   ; FOREIGN SOCKET MUST MATCH TOO
518:         TRNE AC2,177400
519:         JRST CLSRFQ             ; MISMATCH SOMEWHERE, CHECK RFQ LIST
520:         JRST SRCLSR             ; SAME HOST, 
521: 
522: ; HERE, WE HAVE RECEIVED A CLS FROM A HOST THAT IS NOT ACTIVE.
523: ; SEE IF HE IS IN THE RFC QUEUE FOR THIS SOCKET. IF NOT, IGNORE IT.
524: ; SHOULD CHECK FOR MATCHING FOREIGN SOCKET
525: 
526: CLSRFQ: LDB DAT,SRCP            ; PICK UP HOST NUMBER
527:         PUSHJ P,RTNCLS          ; SEND RETURN CLOSE
528:         SETZ TAC1,              ; CLEAR LAST ITEM POINTER
529:         SKIPN AC1,IMPRFQ-1(AC3)
530:         JRST QLEAVE
531: QL1:    LDB DSER,SRCP           ; PICK UP HOST NUMBER
532:         CAIE DAT,(DSER)         ; SAME HOST?
533:         JRST QLOOP              ; NO, GET ANOTHER ONE
534:         PUSHJ P,GSOCK1
535:         CAME AC2,UUO            ; IS THIS THE SAME ONE?
536:         JRST QLOOP
537:         PUSHJ P,UNLRFQ          ; YES, UNLINK QUEUED RFC FROM LIST
538:         PUSHJ P,RELLST          ; FLUSH IT
539: QLEAVE: JRST L0XIT
540: 
541: QLOOP:  MOVE TAC1,AC1
542:         HLRZ AC1,TLINK(AC1)
543:         JUMPN AC1,QL1
544:         JRST QLEAVE
    IMPREG page# 0019 next  prev
546: ; CLS CONTINUED. HERE WE GOT A RECEIVE-SIDE CLS AND THERE IS A LINK TABLE ENTRY.
547: 
548: SRCLSR: MOVSI AC2,CLSR          ; HERE WE ARE THE HOST IN QUESTION
549:         PUSHJ P,CSTAT           ; CHANGE THE CONNECTION STATUS
550:         SKIPN DDB,IMPDDB-1(AC3) ; ANYBODY HOME?
551:         JRST CHCLSS             ; NO
552:         MOVE IOS,DEVIOS(DDB)    ; YES, DOES HE THINK HE WILL GET SOME MORE INPUT?
553:         TLZE IOS,ANYW
554:         PUSHJ P,QRUN            ; YES, BRING HIM OUT OF WAIT
555:         MOVEM IOS,DEVIOS(DDB)   ; SO HE WILL GET EOF
556: CHCLSS: MOVE AC2,IMPSTB-1(AC3)
557:         TLNE AC2,CLSS           ; RECEIVE-SIDE CLS SENT?
558:         JRST SRCLWK             ; YES, SEE IF HE IS WAITING FOR US
559:         PUSHJ P,IMPGET          ; GET SOME STORAGE
560:         PUSHJ P,CLKWAIT
561:         PUSHJ P,SNCLS           ; RETURN A CLS TO HIM
562: SRCLWK: SKIPN DDB,IMPDDB-1(AC3)
563: CALLZL: PUSHJ P,ZEROLK          ; NO, CLEAR THE LINK IF WE CAN
564:         JRST L0XIT
    IMPREG page# 0020 next  prev
566: ; ECHO COMMAND
567: 
568: IECO:   PUSH P,AC1
569:         PUSHJ P,IMPGET
570:         PUSHJ P,CLKWAIT
571:         MOVE AC2,(P)            ; PICK UP ADDRESS OF INCOMING MESSAGE
572:         MOVE AC3,TDATA(AC2)     ; TURN MESSAGE RIGHT AROUND
573:         MOVEM AC3,TDATA(AC1)
574:         SETZM TDATA+1(AC1)
575:         MOVEI AC3,10
576:         DPB AC3,SIZEP           ; PUT IN BYTE SIZE
577:         MOVEI AC3,2
578:         DPB AC3,COUNTP          ; AND MESSAGE LENGTH
579:         ILDB AC3,TBP(AC2)       ; PICK UP ECHO BYTE
580:         DPB AC3,BYTE2P          ; AND GIVE IT BACK TO HIM
581:         MOVEI AC3,ERP           ; PUT ECHO REPLY OPCODE IN WITH DATA BYTE INPUTTED
582:         DPB AC3,OPCDP
583:         PUSHJ P,CLKOUT
584:         POP P,AC1
585:         JRST L0XIT
586: 
587: ; ECHO REPLY
588: 
589: IERP:   JRST RILLO              ; WE DON'T SEND ECOS
    IMPREG page# 0021 next  prev
591: ; ERROR - INCOMMING!
592: 
593: IERR:   AOS RERRM
594:         PUSH P,AC1
595:         PUSHJ P,DISDATE
596:         PUSH P,TDATA(AC1)
597:         PUSHJ P,DISERR
598:         [ASCIZ /IMP - WE GOT AN ERROR MESSAGE, #/]
599:         DISARG DEC,RERRM
600:         [ASCIZ /
601: /]
602:         DISARG OCT,<-1(P)>
603:         [ASCIZ /
604: /]
605:         -1
606:         SUB P,[XWD 1,1]
607:         POP P,AC1
608:         MOVEI TAC1,13
609:         PUSH P,TAC1
610:         PUSH P,AC1
611: IEPLOP: ILDB TAC,TBP(AC1)
612:         PUSHJ P,DISLOC
613:         PUSHJ P,DISMES
614:         ASCIZ / /
615:         MOVE AC1,(P)
616:         SOSLE -1(P)
617:         JRST IEPLOP
618:         PUSHJ P,DISMES
619:         ASCIZ /
620: /
621:         POP P,AC1
622:         SUB P,[XWD 1,1]
623:         JRST L0XIT
    IMPREG page# 0022 next  prev
625: ; RESET REPLY
626: 
627: IRRP:   JRST L0XIT
    IMPREG page# 0023 next  prev
629: ; RESET - PURGE OUR TABLES
630: 
631: IRST:   AOS NRSETS
632:         PUSHJ P,FLCWL0          ; FLUSH ALL PENDING MESSAGES TO THIS HOST
633:         PUSH P,AC1
634:         PUSHJ P,IMPGET          ; GET FREE STORAGE FOR A RESET REPLY
635:         PUSHJ P,CLKWAIT
636:         PUSHJ P,CLRBLK
637:         MOVE AC2,(P)
638:         MOVE AC3,TDATA(AC2)     ; STEAL THE LEADER FROM THE INCOMMING MESSAGE
639:         MOVEM AC3,TDATA(AC1)
640:         SETZM TDATA+1(AC1)
641:         MOVEI AC3,10
642:         DPB AC3,SIZEP
643:         MOVEI AC3,1
644:         DPB AC3,COUNTP
645:         MOVEI AC3,3
646:         MOVEM AC3,TWC(AC1)      ; WE WILL SEND OUT THE LEADER AND ONE EXTRA WORD
647:         MOVEI AC3,RRP           ; SET RESET REPLY OPCODE
648:         DPB AC3,OPCDP
649:         PUSHJ P,CLKOUT
650:         POP P,AC1
651:         LDB AC2,ELINKP          ; PICK UP HOST-LINK NUMBER (LINK=0)
652:   SKIPN AC3,FFLNK         ; SCAN LINK TABLE FOR OPEN CONNECTIONS TO HIM
653:         JRST L0XIT
654: IRST2:  MOVEI TAC,(AC2)
655:         XOR TAC,LNKTAB-1(AC3)
656:         TRNN TAC,177400
657:         JRST IRST1
658: IRST3:  SKIPE AC1,IMPRFQ-1(AC3) ; DOES THIS ENTRY HAVE ANY QUEUED RFCS?
659:         JRST SCNIRF             ; YES, SEE IF HE HAS SOME ENTRIES QUEUED
660: IRST5:  SOJG AC3,IRST2
661:         JRST L0XIT
662: 
663: IRST1:  SKIPE DDB,IMPDDB-1(AC3) ; DOES HE HAVE A DDB?
664:         JRST IRST4              ; YES, SET ERROR BITS
665:         SKIPE AC1,IMPRFQ-1(AC3)
666:         PUSHJ P,APNLST          ; APPEND ENTIRE RFC QUEUE ONTO ILIST FOR RE-INTERPRETATION
667:         PUSHJ P,KILLNK          ; NO, DELETE THE LINK ENTIRELY
668:         JRST IRST3
669: 
670: IRST4:  MOVE IOS,DEVIOS(DDB)    ; CLEAR ANY WAIT STATE
671:         TLZE IOS,ANYW
672:         PUSHJ P,QRUN
673:         ORI IOS,RSET!IODERR
674:         MOVEM IOS,DEVIOS(DDB)
675:         MOVSI AC2,CLSS!CLSR     ; PRETEND CONNECTION IS CLOSED
676:         PUSHJ P,CSTAT           ; GIVE HIM THE INTERRUPT
677:         MOVE AC2,IMPLS-1(AC3)   ; PICK UP LOCAL SOCKET NUMBER
678:         TRNN AC2,1              ; IS OUR SIDE THE SEND SIDE?
679:         JRST IRST3              ; NO
680:         SETZM BAL(DDB)          ; YES, NO MORE MESSAGES, PLEASE
681:         SETZM MAL(DDB)
682:         JRST IRST3
    IMPREG page# 0024 next  prev
684: ; RESET - SCAN DOWN THE QUEUED RFC LIST FOR ENTRIES BY THIS GUY
685: 
686: SCNIRF: SETZ TAC1,              ; SET PREDECESSOR TO ZERO
687: SCNNXR: PUSHJ P,LEGAL           ; BLESS THIS BLOCK
688:         JRST [  SETZM IMPRFQ-1(AC3)
689:                 JRST IRST5]
690:         LDB TAC,ELINKP
691:         CAIE TAC,(AC2)
692:         JRST SCNGNX
693:         PUSH P,AC2
694:         PUSH P,TLINK(AC1)       ; SAVE POINTER TO SUCCESSOR
695:         PUSHJ P,UNLRFQ          ; UNLINK RFC FROM LIST
696:         PUSHJ P,RELLST          ; RELEASE THE STORAGE
697:         POP P,AC1               ; GET BACK SUCCESSOR
698:         HLRZS AC1               ; GET POINTER INTO RIGHT HALF
699:         POP P,AC2               ; GET BACK SOURCE NUMBER
700:         JRST SCNCZ
701: 
702: SCNGNX: MOVEI TAC1,(AC1)        ; SET PREDECESSOR TO CURRENT
703:         HLRZ AC1,TLINK(AC1)     ; MOVE DOWN THE LIST
704: SCNCZ:  JUMPN AC1,SCNNXR
705:         JRST IRST5
    IMPREG page# 0025 next  prev
707: ; ERROR RECOVERY SYSTEM. POOT OUT MESSAGES TO EVERYONE WHO THINKS
708: ; HIS LINK IS BLOCKED. WE WILL THEN GET BACK EITHER A BLOCKED LINK
709: ; OR A RFNM, BUT  IN ANY CASE THE LINK WILL BE CLEARED.
710: 
711: ERRREC: SKIPL RECOVER
712:         JRST ERRCNT
713:         SKIPN AC3,FFLNK
714:         JRST ERRL0
715: ERRNXD: SKIPN DDB,IMPDDB-1(AC3)
716:         JRST ERRLIN
717:         MOVE IOS,DEVIOS(DDB)
718:         TRNN IOS,BLOK
719:         JRST ERRLIN
720:         PUSHJ P,IMPGET
721:         PUSHJ P,CLKWAIT
722:         SETZM TDATA(AC1)
723:         SETZM TDATA+1(AC1)
724:         SKIPN AC2,IMPBS-1(AC3)
725:         MOVEI AC2,10
726:         DPB AC2,SIZEP
727:         MOVE AC2,LNKTAB-1(AC3)
728:         DPB AC2,ELINKP
729:         MOVEI AC2,2
730:         MOVEM AC2,TWC(AC1)
731:         PUSHJ P,CLKOUT          ; OUTPUT A ZERO LENGTH MESSAGE
732: ERRLIN: SOJG AC3,ERRNXD
    IMPREG page# 0026 next  prev
734: ; ERROR RECOVERY FOR LINK ZERO
735: 
736: ERRL0:  MOVEI AC3,7             ;INDEX OF LAST WORD IN L0BLOK TABLE
737: ERRL0L: SKIPN TEM,L0BLOK(AC3)
738:         JRST ERRL0I
739:         MOVEI DAT,1
740:         SETZ TAC,
741: ERRL0T: TDNN DAT,TEM
742:         JRST ERRL0R
743:         PUSHJ P,IMPGET
744:         PUSHJ P,CLKWAIT
745:         SETZM TDATA(AC1)
746:         SETZM TDATA+1(AC1)
747:         SETZM TDATA+2(AC1)
748:         MOVEI TAC1,3
749:         MOVEM TAC1,TWC(AC1)
750:         MOVEI TAC1,10
751:         DPB TAC1,SIZEP
752:         MOVEI TAC1,1
753:         DPB TAC1,COUNTP
754:         MOVEI TAC1,(AC3)
755:         LSH TAC1,5
756:         ORI TAC1,(TAC)
757:         DPB TAC1,SRCP
758:         PUSHJ P,QOUT            ; BYPASS LINK BLOKAGE
759: ERRL0R: ADDI TAC,1
760:         LSH DAT,1
761:         CAIGE TAC,40
762:         JRST ERRL0T
763: ERRL0I: SOJGE AC3,ERRL0L
764:         MOVEI AC1,4*=60*=60
765:         MOVEM AC1,RECOVER
766:         POPJ P,
767: 
768: ERRCNT: SOSGE RECOVER
769:         SETZM RECOVER
770:         POPJ P,
    IMPREG page# 0027 next  prev
772: ; UTILITY ROUTINES FOR THE PRECEEDING ROUTINES - ERROR ROUTINE
773: ; MAKES UP ERROR MESSAGE TO HOST WHOSE INCOMING MESSAGE
774: ; ADDRESS HAS BEEN PUSHED ON THE STACK. SKIPS ON SUCCESS, NON-SKIP
775: ; MEANS NO FREE STORAGE AVAILABLE.
776: 
777: MAKERB: PUSHJ P,IMPGET          ; GET A FREE STORAGE BLOCK
778:         POPJ P,                 ; NONE AVAILABLE
779:         PUSHJ P,CLRBLK          ; ZERO THE FREE STORAGE BLOCK
780:         MOVE AC2,-1(P)          ; PICK UP ADDRESS OF INPUT MESSAGE
781:         LDB AC3,[POINT 16,TDATA(AC2),23]
782:         ANDCMI AC3,377          ; ZERO OUT LINK NUMBER
783:         DPB AC3,ELINKP          ; SET HOST TO THE SAME, LINK TO CONTROL LINK
784:         MOVEI AC3,10
785:         DPB AC3,SIZEP           ; BYTE SIZE FOR CONTROL MESSAGES IS 8
786:         MOVEI AC3,ERR           ; PUT IN ERROR OPCODE
787:         DPB AC3,OPCDP
788:         MOVEI AC3,14            ; ALL ERROR CODES ARE 12 BYTES LONG
789:         DPB AC3,COUNTP
790:         MOVEI AC3,7             ; PICK UP A WORDCOUNT
791:         MOVEM AC3,TWC(AC1)
792:         JRST CPOPJ1
793: 
794: ; ROUTINE TO CLEAR A FREE STORAGE BLOCK.
795: ; ENTER WITH BLOCK ADDRESS IN AC1
796: ; ONLY CLEARS DATA PORTION
797: 
798: CLRBLK: PUSH P,AC2
799:         PUSH P,AC3
800:         SETZM TDATA(AC1)
801:         HRLI AC2,TDATA(AC1)     ; MAKE UP BLT POINTER
802:         HRRI AC2,TDATA+1(AC1)
803:         HRRI AC3,TDATA-1(AC1)
804:         ADD AC3,TLEN(AC1)
805:         BLT AC2,(AC3)
806:         POP P,AC3
807:         POP P,AC2
808:         POPJ P,
    IMPREG page# 0028 next  prev
810: ; ROUTINE TO DELETE A LINK IN THE LINK TABLE.
811: ; ENTER WITH THE LINK TABLE INDEX (PLUS ONE) IN AC3
812: 
813: KILLNK: SKIPE AC1,IMPRFQ-1(AC3) ; ANY QUEUED RFCS HERE?
814:         PUSHJ P,APNLST          ; YES, RECYCLE THEM
815:         MOVEI AC2,-1(AC3)       ; CORRECT INDEX
816:         PUSH P,DAT
817:         SOSE DAT,FFLNK          ; DECREMENT FIRST FREE LINK NUMBER
818:         CAIN DAT,(AC2)          ; IS THIS LINK THE TOP ONE?
819:         JRST KILLN1             ; YES, RESTORE ACS AND LEAVE
820:         PUSH P,AC2
821:         PUSH P,AC3
822:         MOVE AC3,LNKTAB(DAT)
823:         MOVEM AC3,LNKTAB(AC2)
824:         MOVE AC3,IMPDDB(DAT)
825:         MOVEM AC3,IMPDDB(AC2)
826:         MOVE AC3,IMPLS(DAT)
827:         MOVEM AC3,IMPLS(AC2)
828:         MOVE AC3,IMPFS(DAT)
829:         MOVEM AC3,IMPFS(AC2)
830:         MOVE AC3,IMPRFQ(DAT)
831:        MOVEM AC3,IMPRFQ(AC2)
832:         MOVE AC3,IMPBS(DAT)
833:         MOVEM AC3,IMPBS(AC2)
834:         MOVE AC3,IMPSTB(DAT)
835:         MOVEM AC3,IMPSTB(AC2)
836:         POP P,AC3
837:         POP P,AC2
838: KILLN1: POP P,DAT
839:         POPJ P,
    IMPREG page# 0029 next  prev
841: ; ROUTINE TO POLL ALL THE OTHER SITES FOR SIGNS OF LIFE
842: 
843: POLL:   MOVEI AC1,POLTIM
844:         MOVEM AC1,POLCNT
845:         SKIPE IMPDEAD
846:         POPJ P,
847:         SOSG HCLSCT             ; TIME TO CHECK HALF-DEAD SOCKETS YET?
848:         PUSHJ P,HCLSS           ; YES, DO IT NOW
849:         SKIPE IMPECT            ; ANY ERROR BITS?
850:         JRST IERBD
    IMPREG page# 0030 next  prev
852: ; ROUTINE TO PERIODICALLY CHECK AND MAKE SURE ALL IS OK
853: ; IT DELETES HALF-CLOSED SOCKETS PERIODICALLY
854: 
855: HCLSS:  MOVEI AC1,HCLSTM
856:         MOVEM AC1,HCLSCT
857: HCLSR:  SKIPN AC3,FFLNK
858:         POPJ P,
859: HCLSL:  SKIPE IMPDDB-1(AC3)
860: HCLSI:  SOJG AC3,HCLSL
861:         JUMPE AC3,CPOPJ
862:         MOVE AC1,IMPSTB-1(AC3)
863:         TLNE AC1,CLSS
864:         TLNE AC1,CLSR
865:         JRST HCLSI
866:         TLNE AC1,LONCE
867:         JRST HCLSZ
868:         MOVSI AC1,LONCE
869:         ORM AC1,IMPSTB-1(AC3)
870:         JRST HCLSI
871: 
872: HCLSZ:  SKIPE AC1,IMPRFQ-1(AC3) ; GIVE BACK ANY QUEUED RFCS WHAT MAY BE
873:         PUSHJ P,APNLST
874:         PUSHJ P,KILLNK
875:         JRST HCLSR              ; GO BACK AND TRY AGAIN
876: 
877: ; TYPE OUT ERROR MESSAGE ON IMP ERROR BIT DETECTED
878: ; WE OUGHT TO SOMEHOW CLEAR THE INTERFACE TOO
879: 
880: IERBD:  SKIPE IMPDEAD
881:         POPJ P,
882:         SETZM IMPECT            ; START COUNTING AGAIN
883:         SKIPN RECOVER           ; INITIATE ERROR RECOVERY SEQUENCE
884:         SETOM RECOVER
885:         TELCTR(IERBIT,<IMP ERROR BIT CAME UP,>)
886:         POPJ P,
    IMPREG page# 0031 next  prev
888: ; ROUTINE TO SEND THE IMP SOME NOPS
889: 
890: SNDNOP: MOVEI AC3,4
891:         MOVEM AC3,NOPCNT
892:         SETOM IMPOACT
893:         MOVEI AC3,MAXCNT
894:         MOVEM AC3,IMPOCT
895:         CONO PI,IMPOFF
896:         CONO IMP,STROUT!ODPIEN!IMPCHN
897:         DATAO IMP,[BYTE (8) 4]  ;NOP
898:         CONO PI,IMPON
899:         POPJ P,
    IMPREG page# 0032 next  prev
    IMPREG page# 0033 next  prev
902: ; ROUTINE TO DUMP AN INCOMMING COMMAND INTO THE DATA PORTION OF AN ERROR MESSAGE
903: ; ENTER WITH ERROR MESSAGE IN AC1
904: ; OFFENDING INCOMMING MESSAGE AT -1(P)
905: 
906: EFILL:  MOVEI DAT,12
907:         HRRZI AC2,TDATA+2(AC1)
908:         HRLI AC2,(<POINT 8,0,15>)
909: EFILL1: HRRZ AC3,-1(P)
910:         ADD AC3,[POINT 8,TDATA+2]
911: EFILL2: ILDB DSER,AC3
912:         IDPB DSER,AC2
913:         SOJG DAT,EFILL2
914:         POPJ P,
915: 
916: ; SAME THING EXCEPT FOR STANFORD IDIOSYNCRATIC ERROR MESSAGES.
917: ; DUMPS ONE LESS BYTE ONE BYTE FURTHER DOWN
918: 
919: OFILL:  MOVEI DAT,11
920:         HRRZI AC2,TDATA+2(AC1)
921:         HRLI AC2,(<POINT 8,0,23>)
922:         JRST EFILL1
    IMPREG page# 0034 next  prev
924: ; ROUTINE TO WAIT AT CLOCK LEVEL FOR A STANDARD FREE STORAGE BLOCK
925: 
926: CLKWAIT:
927:         SETOM IMPCLW            ; NOTE THAT WE ARE WAITING
928:         PUSHACS                 ; SAVE OUR STATE
929:         MOVEM P,IMPPDP
930:         MOVE AC1,[XWD CLKPDL,IMPSAV]
931:         BLT AC1,IMPSAV+CLKPLN-1 ; SAVE THE STACK
932:         MOVE P,IMPFP
933:         POPJ P,                 ; RETURN TO CLKSER
934: 
935: CLKWT:  PUSHJ P,IMPGET
936:         POPJ P,
937:         MOVE AC3,[XWD IMPSAV,CLKPDL]
938:         BLT AC3,CLKPDL+CLKPLN-1
939:         MOVE P,IMPPDP
940:         PUSHJ P,IMPREL          ;GIVE BLOCK BACK (PROBABLY TO SPARE LIST)
941:         POPACS
942:         SETZM IMPCLW
943:         SOS (P)
944:         SOS (P)                 ; BACK UP TO TRY OFFENDING ROUTINE OVER AGAIN
945:         POPJ P,
    IMPREG page# 0035 next  prev
947: ; ROUTINE TO RELEASE THE STORAGE IN A LIST
948: ; CALL WITH LIST IN AC1
949: 
950: RELLST: HRRZS AC1
951:         PUSHJ P,LEGAL           ; IS THIS A LEGAL BLOCK?
952:         POPJ P,                 ; NO, LEAVE NOW
953:         PUSH P,TLINK(AC1)       ; SAVE POINTER TO NEXT BLOCK
954:         PUSHJ P,IMPREL          ; RELEASE STORAGE
955:         POP P,AC1               ; GET PTR TO NEXT BLOCK
956:         TRNE AC1,-1
957:         JRST RELLST
958:         POPJ P,
959: 
960: ; ROUTINE TO RELEASE LIST OF LISTS
961: ; ENTER WITH LIST LIST IN AC1
962: 
963: RELBLS: PUSHJ P,LEGAL
964:         POPJ P,
965:         PUSH P,TLINK(AC1)
966:         PUSHJ P,RELLST
967:         POP P,AC1
968:         HLRZS AC1
969:         JUMPN AC1,RELBLS
970:         POPJ P,
    IMPREG page# 0036 next  prev
972: ; ROUTINE TO PLANT AN INTERRUPT REQUEST
973: ; MUST HAVE DDB SET UP
974: ; ENTER WITH INTERRUPT BIT IN AC2
975: 
976: INTCOM: LDB J,PJOBN
977:         TDNN AC2,JBTIEN(J)
978:         POPJ P,
979:         IORM AC2,JBTIRQ(J)
980:         SETOM INTREQ(PID)
981:         POPJ P,
    IMPREG page# 0037 next  prev
983: ; ROUTINE TO UNLINK THE TOP MESSAGE ON THE INPUT LIST
984: ; SKIPS IF THERE ACTUALLY WAS ONE AND PUTS ITS ADDRESS IN AC1
985: 
986: UNLMES: CONO PI,IMPOFF
987:         SKIPN AC1,ILIST         ; PICK UP INPUT LIST
988:         JRST UNLME1
989:         HLRZ AC2,TLINK(AC1)     ; GET POINTER TO NEXT LIST
990:         HRRM AC2,ILIST
991:         SKIPN AC2
992:         SETZM ILIST
993:         CONO PI,IMPON
994:         HRRZS TLINK(AC1)        ; CLEAR OUT POINTER TO NEXT BLOCK
995:         JRST CPOPJ1
996: 
997: UNLME1: CONO PI,IMPON
998:         POPJ P,
999: 
1000: ; SAME THING BUT IS ERROR IF NO LIST THERE
1001: 
1002: UNLNS:  PUSHJ P,UNLMES
1003:         JRST UNLERR
1004:         POPJ P,
1005: 
1006: UNLERR: PUSHJ P,DISMES
1007:         [ASCIZ /NO INPUT LIST AT UNLNS
1008: /]
1009:         -1
1010:         SETOM DISFLAG
1011:         PUSHJ P,DISFLUSH
1012:         JRST AUTOLOAD
1013: 
1014: ; ROUTINE TO POP THE FIRST TRANSFER OFF THE INPUT LIST AND DELETE IT
1015: 
1016: POPMESS:
1017:         PUSHJ P,UNLMES
1018:         POPJ P,
1019:         JRST RELLST
    IMPREG page# 0038 next  prev
1021: ; ROUTINE TO SEND OUT A MESSAGE FROM CLOCK LEVEL ON LINK 0.
1022: ; IF LINK IS BLOCKED, PUTS MESSAGE ON A LIST (L0CWTL)
1023: ; ENTER WITH MESSAGE TO BE SENT IN AC1
1024: ; PRESERVEC AC3, BUT DEFINITELY CLOBBERS AC2
1025: 
1026: CLKOUT: SKIPE IMPDEAD
1027:         JRST RELLST             ; IF IMP DEAD, FLUSH OUTPUT
1028: CLKOUD: LDB AC2,TYPEP           ; PICK UP MESSAGE TYPE
1029:         JUMPE AC2,CLKOU4        ; IF A REGULAR MESSAGE, BLOCK LINK FIRST
1030:         CAIN AC2,5              ; IF REGULAR MESSAGE FOR DISCARD, BLOCK LINK ALSO
1031:         JRST CLKOU4
1032:         JRST QOUT               ; OTHERWISE, DON'T WORRY ABOUT TRYING TO BLOCK IT
1033: 
1034: CLKOU4: PUSH P,AC3
1035:         PUSHJ P,L0PTR
1036:         TDNN AC3,L0BLOK(AC2)    ; IS THIS LINK BLOCKED?
1037:         JRST CLKOU3             ; NO, SEND AWAY
1038:         SKIPN AC2,L0CWTL        ; YES, PUT IT ON END OF LIST
1039:         JRST CLKOU1             ; NO LIST, PUT IT ON BOTH ENDS
1040:         MOVSS AC2
1041:         HRLM AC1,TLINK(AC2)     ; LINK US ON TO END OF LAST GUY
1042: CLKOU2: HRLM AC1,L0CWTL
1043:         HRRZS TLINK(AC1)
1044:         POP P,AC3
1045:         POPJ P,
1046: 
1047: CLKOU1: HRRM AC1,L0CWTL
1048:         JRST CLKOU2
1049: 
1050: CLKOU3: ORM AC3,L0BLOK(AC2)     ; BLOCK LINK
1051:         POP P,AC3
1052:         JRST QOUT               ; OUTPUT MESSAGE
    IMPREG page# 0039 next  prev
1054: ; ROUTINE TO FIND A DDB FROM LINK NUMBER IN A SECOND LEVEL
1055: ; NCP COMMAND. GETS SEND OR RECEIVE SIDE AS SPECIFIED.
1056: ; RETURNS:
1057: ; +1 FOR NO SUCH LINK NUMBER
1058: ; +2 FOR WRONG SIDE ONLY
1059: ; +3 FOR SOCKET THERE BUT NO DDB
1060: 
1061: COMDDR: SKIPA DDB,[TRNE TEM,1]  ; GET RECEIVE SIDE SOCKET NUMBER TEST
1062: COMDDS: MOVE DDB,[TRNN TEM,1]   ; PICK SEND SIDE TEST
1063:         LDB AC2,SRCP            ; PICK UP HOST NUMBER
1064:         LSH AC2,=8
1065:         ILDB AC3,TBP(AC1)
1066:         ORI AC2,(AC3)           ; MAKE UP HOST-LINK NUMBER
1067:         SETZ DAT,
1068:         SKIPN AC3,FFLNK         ; PICK UP POINTER TO FIRST FREE LINK
1069:         POPJ P,
1070: COMDS2: CAMN AC2,LNKTAB-1(AC3)  ; HOST-LINK NUMBER MATCH?
1071:         JRST COMDS1
1072: COMDS3: SOJG AC3,COMDS2
1073:         SKIPE AC3,DAT           ; DID WE FIND ANYTHING AT ALL?
1074:         AOS (P)                 ; YES, GIVE +2 RETURN
1075:         POPJ P,
1076: 
1077: COMDS1: MOVEI DAT,(AC3)         ; SAVE INDEX FOR FUTURE REFERENCE
1078:         MOVE TEM,IMPLS-1(AC3)
1079:         XCT DDB
1080:         JRST COMDS3
1081:         AOS (P)
1082:         AOS (P)
1083:         SKIPE DDB,IMPDDB-1(AC3)
1084:         AOS (P)
1085:         POPJ P,
    IMPREG page# 0040 next  prev
1087: ; ROUTINES TO PICK UP SOCKET NUMBERS AND STORE THEM FOR CLS, RTS, AND STR
1088: 
1089: RD2B:   ILDB AC2,TBP(AC1)
1090:         LSH AC2,10
1091:         ILDB TEM,TBP(AC1)
1092:         ORI AC2,(TEM)
1093:         POPJ P,
1094: 
1095: RD4B:   ILDB AC2,TBP(AC1)
1096: REPEAT 3,<
1097:         LSH AC2,10
1098:         ILDB TEM,TBP(AC1)
1099:         ORI AC2,(TEM)
1100: >
1101:         POPJ P,
1102: 
1103: PSOCK1: DPB AC2,SOK1BP
1104:         LSH AC2,-10
1105:         DPB AC2,SOK1AP
1106:         POPJ P,
1107: 
1108: PSOCK2: DPB AC2,SOK2BP
1109:         LSH AC2,-10
1110:         DPB AC2,SOK2AP
1111:         POPJ P,
1112: 
1113: GSOCK1: LDB AC2,SOK1AP
1114:         LDB TEM,SOK1BP
1115:         LSH AC2,10
1116:         ORI AC2,(TEM)
1117:         POPJ P,
1118: 
1119: GSOCK2: LDB AC2,SOK2AP
1120:         LDB TEM,SOK2BP
1121:         LSH AC2,10
1122:         ORI AC2,(TEM)
1123:         POPJ P,
    IMPREG page# 0041 next  prev
1125: ; ROUTINE TO RETURN A CLS TO THE HOST WHOSE MESSAGE IS IN AC1
1126: ; RETURNS MESSAGE TO FREE STORAGE.
1127: 
1128: RTNCLS: MOVE AC2,TDATA(AC1)
1129:         PUSH P,AC1
1130:         PUSHJ P,IMPGET
1131:         PUSHJ P,CLKWAIT
1132:         PUSHJ P,MCLSB           ; MAKE UP A CLS LOCK
1133:         MOVE AC2,JDAT
1134:         PUSHJ P,PSOCK1
1135:         MOVE AC2,UUO
1136:         PUSHJ P,PSOCK2
1137:         PUSHJ P,CLKOUT
1138:         POP P,AC1
1139:         POPJ P,
    IMPREG page# 0042 next  prev
1141: ; ROUTINE TO MAKE UP A CLS BLOCK WITH EMPTY SOCKETS
1142: ; CALL WITH IMP HEADER IN AC2
1143: ; MUST ALREADY HAVE FREE STORAGE IN AC1
1144: 
1145: MCLSB:  MOVEM AC2,TDATA(AC1)
1146:         SETZM TDATA+1(AC1)
1147:         SETZM TDATA+2(AC1)
1148:         SETZM TDATA+3(AC1)
1149:         SETZM TDATA+4(AC1)
1150:         MOVEI AC2,5             ; FIVE WORD TRANSFER
1151:         MOVEM AC2,TWC(AC1)
1152:         MOVEI AC2,10
1153:         DPB AC2,SIZEP
1154:         MOVEI AC2,11
1155:         DPB AC2,COUNTP
1156:         MOVEI AC2,CLS
1157:         DPB AC2,OPCDP
1158:         POPJ P,
    IMPREG page# 0043 next  prev
1160: ; SEND CLOSE TO FOREIGN HOST
1161: ; CALL WITH FREE STORAGE IN AC1
1162: ; CONNECTION INDEX MUST BE IN AC3
1163: 
1164: SNCLS:  MOVE AC2,LNKTAB-1(AC3)
1165:         ANDI AC2,177400
1166:         LSH AC2,14
1167:         PUSHJ P,MCLSB
1168:         MOVE AC2,IMPLS-1(AC3)
1169:         SKIPE DDB,IMPDDB-1(AC3) ; MAKE SURE THERE IS A DDB THERE
1170:         TRNN AC2,1              ; IS OUR SIDE THE SEND SIDE?
1171:         JRST SNCLS1             ; NO
1172:         SETZM BAL(DDB)          ; YES, DON'T EMIT ANY MORE MESSAGES
1173:         SETZM MAL(DDB)
1174: SNCLS1: PUSHJ P,PSOCK1
1175:         MOVE AC2,IMPFS-1(AC3)
1176:         PUSHJ P,PSOCK2
1177:         PUSHJ P,CLKOUT
1178:         MOVSI AC2,CLSS
1179:         PUSHJ P,CSTAT
1180:         POPJ P,
 EOF: IMPREG end-of-file. cnt=41